
'''
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License") you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
'''
from base.datatypes.xsd.impl import RDFhtml, RDFLangString, XMLLiteralType, RDFjson
from base.rdf.ResourceFactory import ResourceFactory

# package org.apache.jena.vocabulary
# 
# import org.apache.jena.datatypes.RDFDatatype
# import org.apache.jena.datatypes.xsd.impl.RDFLangString
# import org.apache.jena.datatypes.xsd.impl.RDFhtml
# import org.apache.jena.datatypes.xsd.impl.RDFjson
# import org.apache.jena.datatypes.xsd.impl.XMLLiteralType
# import org.apache.jena.graph.Node
# import org.apache.jena.rdf.model.Property
# import org.apache.jena.rdf.model.Resource
# import org.apache.jena.rdf.model.ResourceFactory

uri = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"

'''
     * returns the URI for this schema
     *
     * @return the URI for this schema
    '''
def getURI():
    return uri


def resource(local):
    return ResourceFactory.createResourceWithUri(uri + local)


def property(local):
    return ResourceFactory.createPropertyWithNameSpaceAndLocalName(uri, local)


'''
 * RDF constants are used during Jena initialization.
 * <p>
 * If that initialization is triggered by touching the RDF class,
 * then the constants are null.
 * <p>
 * So for these cases, call this helper class: Init.function()
'''


class Init:

    # JENA-1294
    # Version that calculates the constant when called.
    @staticmethod
    def Alt():
        return resource("Alt")

    @staticmethod
    def Bag():
        return resource("Bag")

    # Java8 bug : https://bugzilla.redhat.com/show_bug.cgi?id=1423421
    # Can't have a method called Property() - it crashes the javadoc generation.
    #  https://bugzilla.redhat.com/show_bug.cgi?id=1423421 ==>
    #  https://bugs.openjdk.java.net/browse/JDK-8061305
    @staticmethod
    def Property():
        return resource("property(")

    @staticmethod
    def Seq():
        return resource("Seq")

    @staticmethod
    def Statement():
        return resource("Statement")

    @staticmethod
    def List():
        return resource("List")

    @staticmethod
    def nil():
        return resource("nil")

    @staticmethod
    def first():
        return property("first")

    @staticmethod
    def rest():
        return property("rest")

    @staticmethod
    def subject():
        return property("subject")

    @staticmethod
    def predicate():
        return property("predicate")

    @staticmethod
    def object():
        return property("object")

    @staticmethod
    def type():
        return property("type")

    @staticmethod
    def value():
        return property("value")

    @staticmethod
    def dtRDFHTML():
        return RDFhtml.rdfHTML

    @staticmethod
    def dtLangString():
        return RDFLangString.rdfLangString

    @staticmethod
    def dtXMLLiteral():
        return XMLLiteralType.theXMLLiteralType

    @staticmethod
    def dtRDFJSON():
        return RDFjson.rdfJSON

    @staticmethod
    def langString():
        return ResourceFactory.createResourceWithUri(Init.dtLangString().getURI())

    @staticmethod
    def HTML():
        return ResourceFactory.createResourceWithUri(Init.dtRDFHTML().getURI())

    @staticmethod
    def xmlLiteral():
        return ResourceFactory.createResourceWithUri(Init.dtXMLLiteral().getURI())

    @staticmethod
    def JSON():
        return ResourceFactory.createResourceWithUri(Init.dtRDFJSON().getURI())

    @staticmethod
    def CompoundLiteral():
        return resource("CompoundLiteral")

    @staticmethod
    def language():
        return property("language")

    @staticmethod
    def direction():
        return property("direction")


class RDF:

    '''
     * The namespace of the vocabulary as a string
    '''
    # public static final String 
    
    @staticmethod
    def li(i):
        return property("_" + i)

    @staticmethod
    def getURI():
        return uri
    

    Alt = Init.Alt()
    Bag = Init.Bag()
    Property = Init.Property()
    Seq = Init.Seq()
    Statement = Init.Statement()
    List = Init.List()
    nil = Init.nil()

    first = Init.first()
    rest = Init.rest()
    subject = Init.subject()
    predicate = Init.predicate()
    object = Init.object()
    type = Init.type()
    value = Init.value()

    # RDF 1.1 - the datatypes of language strings
    langString = Init.langString()

    # RDF 1.1 - rdf:HTML
    HTML = Init.HTML()

    # rdf:XMLLiteral
    xmlLiteral = Init.xmlLiteral()

    # public static final RDFDatatype 
    dtRDFHTML = Init.dtRDFHTML()
    dtLangString = Init.dtLangString()
    dtXMLLiteral = Init.dtXMLLiteral()

    # Added to the RDF namespace December 2019
    # https://lists.w3.org/Archives/Public/semantic-web/2019Dec/0027.html

    # rdfs:comment "The datatype of RDF literals storing JSON content."
    dtRDFJSON = Init.dtRDFJSON()
    JSON = Init.JSON()

    # rdfs:comment "A class representing a compound literal."
    CompoundLiteral = Init.CompoundLiteral()

    # rdfs:comment "The language component of a CompoundLiteral."
    language = Init.language()

    # rdfs:comment "The base direction component of a CompoundLiteral."
    direction = Init.direction()


'''
 * The same items of vocabulary, but at the Node level, parked inside a
 * nested class so that there's a simple way to refer to them.
'''
# @SuppressWarnings("hiding")
class Nodes:
    Alt = Init.Alt().asNode()
    Bag = Init.Bag().asNode()
    Property = Init.Property().asNode()
    Seq = Init.Seq().asNode()
    Statement = Init.Statement().asNode()
    List = Init.List().asNode()
    nil = Init.nil().asNode()
    first = Init.first().asNode()
    rest = Init.rest().asNode()
    subject = Init.subject().asNode()
    predicate = Init.predicate().asNode()
    object = Init.object().asNode()
    type = Init.type().asNode()
    value = Init.value().asNode()
    langString = Init.langString().asNode()
    HTML = Init.HTML().asNode()
    xmlLiteral = Init.xmlLiteral().asNode()
    # Added to the RDF namespace December 2019
    # https://lists.w3.org/Archives/Public/semantic-web/2019Dec/0027.html
    JSON = Init.JSON().asNode()
    CompoundLiteral = Init.CompoundLiteral().asNode()
    language = Init.language().asNode()
    direction = Init.direction().asNode()
    

